Automatic Loading and Unloading of Objects
Another way that QuickDraw GX minimizes memory requirements is by moving objects back and forth between memory and external storage as needed. If QuickDraw GX needs additional memory to create new objects, it can unload objects that are already in memory. When unloaded, an object is moved from computer memory to temporary private storage on disk. When loaded, that object is restored to normal object form in memory.Typically, QuickDraw GX unloads objects that have not been accessed recently before unloading objects that your application has been using frequently. Also, for shape objects, QuickDraw GX provides flags that you can set to notify QuickDraw GX that you want it to unload a given shape before all others, or unload it after all others, when more memory is needed.
To reference and use an object, you needn't be concerned with or even know whether it is in a loaded or unloaded state. QuickDraw GX automatically loads any unloaded object when it is needed, even if that means unloading another object to make room.
For some purposes, such as measuring the storage size of an object, you may need to have the object in memory. Conversely, in other situations you may wish to allow an object to leave memory temporarily, to make more room in the QuickDraw GX heap. QuickDraw GX provides functions (such as
GXLoadShape
andGXUnloadShape
) that you can use to explicitly load or unload an object.The
GXLoadShape
andGXUnloadShape
functions, and other loading and
unloading calls, are described in the memory management chapter of Inside Macintosh: QuickDraw GX Environment and Utilities. The flags that affect the loading and unloading priority for shapes are described under shape attributes in the chapter "Shape Objects" in this book.